package com.wanmait.myhouse.webController;

import com.wanmait.myhouse.dao.HouseDAO;
import com.wanmait.myhouse.vo.House;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.List;

@Controller
@RequestMapping("web")
public class WebIndexController {
    @GetMapping("mistake")
    public String mistake(){
        return "/web/404";
    }
    @GetMapping("exit")
    public String exit(HttpSession session){
        session.invalidate();
        return "redirect:/web/index";
    }
   @GetMapping("index")
    public String index(Model model){
       HouseDAO houseDAO = new HouseDAO();
       List<House> houseList = houseDAO.selectAll();
       model.addAttribute("houseList",houseList);
       return "web/index";
    }
}
